package monster.flight.admin.action.xtgl.dict;

import java.util.List;

import monster.comm.action.BaseJsonAction;
import monster.comm.log.ILog;
import monster.comm.log.LogService;
import monster.comm.util.ReturnConstant;
import monster.flight.admin.manager.service.xtgl.DictService;
import monster.flight.comm.entity.vo.Xt_dict;
import monster.flight.comm.entity.vo.Xt_dict_detail;

/**
 * 
* 创建信息=============
* 类名: monster.flight.admin.action.xtgl.dict.DictDetailListByDictSnAction
* 类作用描述: 根据参数dict_sn查询与之对应的字典明细项，并将结果封装在一个list中返回给页面
* 创建人： zhongjianjun
* 创建时间： 2013-1-25 上午11:25:17
* 修改信息1=============
* 修改类型:     //1.修改bug 2.业务变化修改
* 修改描述: 
* 修改人：  
* 修改时间：
 */
public class DictDetailInitAction extends BaseJsonAction{
	 private static final long serialVersionUID = 1L;
	 private static ILog log = LogService.getLog(DictDetailInitAction.class);
	 private DictService dictService;
	 private List<Xt_dict_detail> dictDetailList;
	 private String dict_sn;   //页面传过来的字典项流水号
	 
	public List<Xt_dict_detail> getDictDetailList() {
		return dictDetailList;
	}
	public void setDict_sn(String dict_sn) {
		this.dict_sn = dict_sn;
	}
	
	public void setDictService(DictService dictService) {
		this.dictService = dictService;
	}

	/**
	 * 根据dict_sn查询数据字典明细
	 */
	public String findList(){
		String islogin = this.isLogin();
		if("0".equals(islogin)){
			returnVO.returnCode=ReturnConstant.IS_NOT_LOGIN;
	    	returnVO.returnDesc="没有登录";
		}
		if("1".equals(islogin)){
			 try {
				 Xt_dict_detail dictDetailTmp = new Xt_dict_detail();
				 dictDetailTmp.setDict_sn(dict_sn);
				 dictDetailList = dictService.getDictDetailList(dictDetailTmp);
				 Xt_dict dict = dictService.getPoByKey(dict_sn);
				 Xt_dict_detail dictDetail = new Xt_dict_detail();
				 dictDetail.setOption_sn("0");
				 dictDetail.setDict_code(dict.getDict_code());
				 dictDetail.setOption_name(dict.getDict_name());
				 dictDetail.setParent_code("-1");
				 dictDetail.setLevel_index("0");
				 dictDetailList.add(dictDetail);
				 returnVO.returnCode=ReturnConstant.IS_DEAL_OK;
				 returnVO.returnDesc="操作成功";
			} catch (Exception e) {
				returnVO.returnCode=ReturnConstant.IS_ERR;
        		returnVO.returnDesc="查询数据字典项明细失败!";
        		log.error(e.getMessage());
			}
		}
		return "success";
	}

}
